<template>
  <div class="box">
    <img src="../../assets/banner.png" alt="" @click="su = true" />
    <teleport to="body">
      <div v-if="su" class="mask">
        <div class="image">
          <div id="dian">
            <div class="Shang">
              <div
                class="Pin"
                :class="{ active: item.id === sel }"
                v-for="item in to"
                @click="select(item)"
              >
                {{ item.type }}
              </div>
            </div>

            <div class="nav">
              <div v-show="sel === 1">
                <p>拼团规则</p>
                <p>1.在商品详情页付款后，可在我的-订单里分享给好友</p>
                <p>2.在商品详情页付款后，可在我的-订单里分享给好友</p>
                <p>3.在商品详情页付款后，可在我的-订单里分享给好友</p>
              </div>
              <div v-show="sel === 2">
                <p>拼团攻略</p>
                <p>1.在商品详情页付款后，可在我的-订单里分享给好友</p>
                <p>2.在商品详情页付款后，可在我的-订单里分享给好友</p>
                <p>3.在商品详情页付款后，可在我的-订单里分享给好友</p>
              </div>
            </div>
          </div>
          <img
            src="../../assets/quxiao.png"
            alt=""
            class="imgs"
            @click="su = false"
          />
        </div>
      </div>
    </teleport>
  </div>
</template>

<script>
import { ref } from "vue";
export default {
  name: "TanChuAng",
  data() {
    return {
      sel: 1,
      to: [
        {
          type: "拼团规则",
          id: 1,
        },
        {
          type: "拼团攻略",
          id: 2,
        },
      ],
    };
  },
  methods: {
    select(item) {
      this.sel = item.id;
    },
  },
  setup() {
    let su = ref(false);
    return {
      su,
    };
  },
};
</script>

<style lang="less" scoped>
.mask {
  z-index: 999;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(59, 58, 58, 0.5);
  overflow: hidden;
  .image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    #dian {
      border-radius: 15px;
      width: 15rem;
      height: 15rem;
      background-color: rgb(255, 255, 255);
      overflow: hidden;
      .Shang {
        display: flex;
        .Pin {
          height: 2rem;
          width: 100%;
          background-color: rgb(214, 214, 214);
          text-align: center;
          font-size: 1rem;
          line-height: 2rem;
          color: rgb(5, 5, 5);
        }
      }
      .Pin.active {
        background-color: rgb(220, 117, 20);
        color: rgb(255, 255, 255);
      }
      .nav {
        margin: 0.5rem 1rem;
        font-size: 0.8rem;
      }
    }
    .imgs {
      height: 2rem;
      position: absolute;
      bottom: -3rem;
      left: 50%;
      transform: translate(-50%);
    }
  }
}

.box {
  width: 100%;
  display: flex;
  img {
    padding: 0.5rem 0;
    height: 4rem;
    display: inline-block;
    margin: 0 auto;
  }
}
</style>